09. Quiz: I hereby promise…
Accessing the database in the main thread can be time consuming, and could lock the UI and throw an Application Not Responding error. To avoid that, Room will, by default, throw an error if you attempt to access the database in the main thread.
In the finished app, we need to implement the database operations to run asynchronously, but we also need to validate that what we have done so far is working, so let’s temporarily enable the option to allow queries in the main thread.
Before going ahead
SOLUTION:
- I will not run queries in the main thread in production. I understand that this is just enabled temporarily to verify our implementation. I guarantee that I will disable this option immediately after this test, and I will implement the queries asynchronously.